import 'package:flutter/material.dart';
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
import 'package:tencent_cloud_chat_demo/src/pages/login.dart';
import 'package:tencent_cloud_chat_demo/src/routes.dart';
import 'package:tencent_cloud_chat_demo/utils/commonUtils.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
import 'package:tencent_cloud_chat_demo/src/provider/theme.dart';
import 'package:provider/provider.dart';

class RegisterSuccess extends StatefulWidget {
  final String account;
  final String securityQ;
  final String securityA;
  final String password;

  const RegisterSuccess({
    Key? key,
    required this.account,
    required this.securityQ,
    required this.securityA,
    required this.password,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() => RegisterSuccessState();
}

class RegisterSuccessState extends State<RegisterSuccess> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  directToLoginPage() {
    Routes().directToLoginPage();
  }

  @override
  Widget build(BuildContext context) {
    final theme = Provider.of<DefaultThemeData>(context).theme;
    final isWideScreen =
        TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
    return PopScope(
      canPop: false,
      child: Scaffold(
        appBar: isWideScreen
            ? null
            : AppBar(
                leading: Container(),
                iconTheme: const IconThemeData(
                  color: Colors.white,
                ),
                shadowColor: theme.weakDividerColor,
                elevation: 1,
                title: Text(
                  TIM_t("注册成功"),
                  style: const TextStyle(color: Colors.white, fontSize: 17),
                ),
                flexibleSpace: Container(
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      colors: [
                        theme.lightPrimaryColor ??
                            CommonColor.lightPrimaryColor,
                        theme.primaryColor ?? CommonColor.primaryColor
                      ],
                    ),
                  ),
                ),
              ),
        body: Padding(
          padding: const EdgeInsets.fromLTRB(40, 40, 40, 0),
          child: Column(
            children: [
              Container(
                padding: const EdgeInsets.all(16),
                decoration: const BoxDecoration(
                  shape: BoxShape.circle,
                  color: Colors.black,
                ),
                child: const Icon(Icons.check, color: Colors.white, size: 32),
              ),
              const SizedBox(height: 46),
              // 账号信息
              Align(
                alignment: Alignment.center,
                child: SizedBox(
                  width: 200, // 固定宽度
                  child: Text("登录账号：${widget.account}",
                      style: const TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.bold,
                      )),
                ),
              ),
              Align(
                alignment: Alignment.center,
                child: SizedBox(
                  width: 200, // 固定宽度
                  child: Text("登录密码：${widget.password}",
                      style: const TextStyle(
                          fontSize: 16, fontWeight: FontWeight.bold)),
                ),
              ),
              Align(
                alignment: Alignment.center,
                child: SizedBox(
                  width: 200, // 固定宽度
                  child: Text("安全问题：${widget.securityQ}",
                      style: const TextStyle(
                          fontSize: 16, fontWeight: FontWeight.bold)),
                ),
              ),
              Align(
                alignment: Alignment.center,
                child: SizedBox(
                  width: 200, // 固定宽度
                  child: Text("安全答案：${widget.securityA}",
                      style: const TextStyle(
                          fontSize: 16, fontWeight: FontWeight.bold)),
                ),
              ),

              const SizedBox(height: 32),

              Align(
                alignment: Alignment.center,
                child: SizedBox(
                  width: 200, // 固定宽度
                  child: Text(TIM_t("请妥善保管账号密码及安全问题答案"),
                      style: const TextStyle(
                          fontSize: 16, fontWeight: FontWeight.bold)),
                ),
              ),

              Container(
                margin: const EdgeInsets.only(top: 46),
                width: double.infinity,
                child: ElevatedButton(
                  child: Text(TIM_t("去登录"),
                      style: const TextStyle(color: Colors.white)),
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.black,
                  ),
                  onPressed: directToLoginPage,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
